﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nebular.ExpenseManagement.Infrastructure;

namespace Nebular.ExpenseManagement.Model
{
    [Serializable]
    public class CreditCard : MarshalByRefObject, ICreditCard
    {
        readonly Guid _id;
        readonly string _cardNumber;

        public CreditCard(Guid id, string cardNumber)
        {
            _id = id;
            _cardNumber = cardNumber;
        }

        public CreditCard(xpCreditcard creditCard)
            : this(creditCard.Id, creditCard.CardNumber)
        { }


        #region ICreditCard Members

        public string CardNumber
        {
            get
            {
                return _cardNumber;
            }
        }

        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        #endregion

        internal static IEnumerable<ICreditCard> Convert(IEnumerable<xpCreditcard> cards)
        {
            foreach (var card in cards)
                yield return new CreditCard(card);
        }
    }
}
